{% extends '::base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<style>
		label, input.text { display:block; }
		input.text { margin-bottom:12px; width:25%; padding: .4em; }
		
</style>
{% endblock %}
{% block javascripts %}
    {{ parent() }}
    
{{ jqGrid_init() }}    
{% endblock %}
{% block body %}



<div id="accordion">
   <h1> Редактирование даных Фирмы</h1>
   
    
             <h2>Основные данные </h2>
                <div class="left_box">
                        <form action="{{ path('_firm_page') }}" method="POST" id="contact_form">
                            {{ form_label(form.name) }}
                            {{ form_widget(form.name, {'attr': {'class': 'text' } }) }}
                            {{ form_label(form.description) }}
                            {{ form_widget(form.description, {'attr': {'class': 'tinymce', 'tinymce': '{"theme":"simple"}' } }) }}
                            {{ form_label(form.category) }}
                            {{ form_widget(form.category, {'attr': {'class': 'text' } }) }}
                            {{ form_rest(form) }}
                             </br>
                             </br>
                            <input type="submit" value="Сохранить"/>
                        </form>
                 </div>
   <h2>Товары</h2>
   <div class="left_box">
      <table id="list2"></table> 
      <div id="pager2"></div>
   </div>
 </div>
{{ jqGrid_exec({'selector': '#list2', 'params': params}) }}
{% endblock %}
{% block post_init_javascript %}
    $("#list2").jqGrid('navGrid','#pager2',{edit: false, add: false}); 
    $("#list2").jqGrid('navButtonAdd','#pager2',{
                                                      caption: '',
	                                              title: 'Добавить Новый товар',
	                                              buttonicon: 'ui-icon-plus',
	                                              onClickButton: function(){
	                                                                document.location = '{{ path('_add_staff', { 'firm_id': firm_id }) }}';
	                                                             },
	                                              position:'first'
    }).jqGrid('navButtonAdd','#pager2',{
                                                      caption: '',
	                                              title: 'Редактировать',
	                                              buttonicon: 'ui-icon-pencil',
	                                              onClickButton: function(){
	                                                                var gr = $("#list2").jqGrid('getGridParam','selarrrow');
                                                                        if( gr != null && gr.length != 0 ) { 
                                                                          var ret = $("#list2").jqGrid('getRowData',gr[0]);
                                                                          document.location = '{{ path('_add_staff', { 'firm_id': firm_id }) }}/' + ret.id ;
                                                                        } 
                                                                        else{
                                                                            alert("Please Select Row to delete!");
                                                                        }
	                                                             },
	                                              position:'first'
    });
    
    $("input:submit").button();
    $("#accordion").accordion({ header: "h2" });
    
{% endblock %}
{% block post_javascripts%}
    {{ parent() }}
    {{ tinymce_init() }}
{% endblock %}